<meta title="新增服务" width="600px" args="serviceItem" />
<form class="form-horizontal p" s="form,valid,nda,datac" s-data="serviceItem || {}" id="form" method="post" action="/api/serviceItem">
    <div class="form-group">
        <div class="control-label col-sm-2">服务：</div>
        <div class="col-sm-10">
            <select class="form-control" s="select"
                    s-build="S.get('/api/enum/valuesMap/core.enums.Service')"
                    name="service">
            </select>
        </div>
    </div>
    <div class="form-group">
        <div class="control-label col-sm-2">周期：</div>
        <div class="col-sm-10">
            <select class="form-control" s="select"
                    s-build="S.get('/api/enum/valuesMap/core.enums.TimeUnit')"
                    name="timeUnit">
            </select>
        </div>
    </div>
    <div class="form-group">
        <div class="control-label col-sm-2">价格：</div>
        <div class="col-sm-10">
            <input autocomplete="off" type="text" class="form-control" s-valid-error="require(),number()" name="price"/>
        </div>
    </div>
    <div class="form-group">
        <div class="control-label col-sm-2">状态：</div>
        <div class="col-sm-10">
            <select class="form-control input-sm" s="select"
                    s-build="S.get('/api/enum/valuesMap/core.enums.ServiceItemStatus?igNames=DELETED')"
                    name="status">
            </select>
        </div>
    </div>
</form>
<script type="text/javascript">
    S.meta.btns = [
        {
            name: "新增",
            style: "btn btn-primary",
            click: function() {
                return $form.submit().done(function(rs) {
                    S.close(rs);
                })
            }
        },
        {
            name: "取消",
            style: "btn btn-default",
            click: function() {
                S.close();
            }
        }
    ]
    if(serviceItem) {
        S.meta.btns[0].name = "保存"
        $form.node.attr("method", "put").attr("action", "/api/serviceItem/" + serviceItem.id)
    }
</script>